﻿app.factory('studentService', function ($http, config) {
    var url = config.baseMatriculaUrl + 'api/student';
    var _getList = function () {
        return $http.get(url).then(function (results) {
            return results;
        });
    };
    var _create = function (student) {
        return $http.post(url, student).then(function (results) {
            return results;
        });
    };
    var _delete = function (Id) {
        return $http.delete(url, { params: Id }).then(function (results) {
            return results;
        });
    };
    var _update = function (Id, student) {
        return $http({
            method: 'PUT',
            url: url + "/" + student.Id,
            data: student
        }).then(function (results) {
            return results;
        });
    };

    return {
        getList: _getList,
        create: _create,
        delete: _delete,
        update: _update,
    };
});